﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Routing;

namespace VaccineEbook.Helpers
{
    public static class OtherHelperExtensions
    {
        #region Other
        public static RouteValueDictionary _ToRouteValueDictionary(this NameValueCollection collection)
        {
            RouteValueDictionary dic = new RouteValueDictionary();
            foreach (string key in collection.Keys)
                dic.Add(key, collection[key]);

            return dic;
        }

        /// <summary> N: Add or Update Parameter into Route </summary>
        public static RouteValueDictionary _AddOrUpdate(this RouteValueDictionary dictionary, string key, object value)
        {
            dictionary[key] = value;
            return dictionary;
        }

        /// <summary> N: Add or Update multi Parameter into Route </summary>
        public static RouteValueDictionary _AddOrUpdate(this RouteValueDictionary dictionary, object routeValues)
        {
            RouteValueDictionary newRoute = new RouteValueDictionary(routeValues);
            foreach (var item in newRoute)
            {
                dictionary[item.Key] = item.Value;
            }
            return dictionary;
        }

        /// <summary> N: remove multi Parameter in Route </summary>
        public static RouteValueDictionary _RemoveKeys(this RouteValueDictionary dictionary, params string[] keys)
        {
            foreach (string key in keys)
                dictionary.Remove(key);

            return dictionary;
        }
        #endregion
    }
}